#define _CRT_SECURE_NO_WARNINGS
#include <iostream>

using namespace std;

template<class T>
struct ListNode
{
	ListNode(const T& data)
		:_data(data)
		, _pre(nullptr)
		, _next(nullptr)
	{}

	ListNode(T&& data)
		:_data(move(data))
		, _pre(nullptr)
		, _next(nullptr)
	{}

	T _data;
	ListNode* _pre;
	ListNode* _next;
};

template<class T1,class T2>
class Pair
{
public:
	Pair(const T1& first,const T2& second)
		:_first(first)
		, _second(second)
	{}

private:
	T1 _first;
	T2 _second;
};

class String
{
public:
	typedef char* iterator;

	iterator begin()
	{
		return _ptr;
	}

	iterator end()
	{
		return _ptr + _size;
	}

	void swap(String& s)
	{
		::swap(_ptr, s._ptr);
		::swap(_size, s._size);
		::swap(_capacity, s._capacity);
	}

	String(const String& s)
	{
		_ptr = new char[s._capacity + 1];
		strcpy(_ptr, s._ptr);
		_size = s._size;
		_capacity = s._capacity;
	}

	String(String&& s)
	{
		swap(s);
	}

	String& operator=(const String& s)
	{
		if (this == &s)
			return *this;

		String tmp(s);
		swap(tmp);
		return *this;
	}

	String& operator=(String&& s)
	{
		swap(s);
		return *this;
	}

	~String()
	{
		delete[] _ptr;
		_ptr = nullptr;
	}

private:
	size_t _size = 0;
	size_t _capacity = 0;
	char* _ptr = nullptr;
};

void test1()
{

}

int main()
{
	test1();

	return 0;
}